﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using BaseTypesLib.Model.Fonts;

namespace BaseTypesLib.TypeConverters
{
    public class FontTypeConverter:ExpandableObjectConverter
    {
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (typeof(Font) == destinationType)
                return true;
            return base.CanConvertTo(context, destinationType);
        }
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(System.String) && value is Font)
            {

                Font f = (Font)value;

                return string.Format("{0} {1}", f.Height, f.Style);
            }
            return base.ConvertTo(context, culture, value, destinationType);

        }
    }
}
